package cn.edu.jju.psytest.web;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.jju.psytest.model.vo.StudentVo;
import cn.edu.jju.psytest.model.vo.TeacherVo;
import cn.edu.jju.psytest.service.UserService;

@SuppressWarnings("restriction")
@Controller
@RequestMapping("/register")
public class RegisterController {

	private UserService userService;
	

	@RequestMapping(value = "/student", method = RequestMethod.POST)
	public String registerStudent(StudentVo studentVo) {
		userService.saveUser(studentVo);
		return "redirect:/login";
	}

	@RequestMapping(value = "/teacher", method = RequestMethod.POST)
	@ResponseBody
	public String registerTeacher(TeacherVo teacherVo) {
		System.out.println(teacherVo.getTeacherId());
		System.out.println(teacherVo.getPassword());
		System.out.println(teacherVo.getPrivilege());
		userService.saveUser(teacherVo);
		return "创建成功！";
	}

	/**
	 * Getters And Setters
	 */
	public UserService getUserService() {
		return userService;
	}

	@Resource
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
}
